//
//  JLJTools.h
//  BZW
//
//  Created by Kaka on 16/6/16.
//  Copyright © 2016年 Kaka. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>



typedef enum{
    
    knowNo = 0,
    isWifi,
    isWalan
    
}InternetStatus;

typedef void (^cancelActionBlock)();
typedef void (^sureActionBlock)();
typedef void(^JLJInternalCompletionBlock)(BOOL finished,NSURL * imageURL);
@interface JLJTools : NSObject

+ (instancetype)shareInstance;
/**
 *  设置圆角View
 *
 *  @param view    view
 *  @param width   边线的宽度
 *  @param radius  圆角的大小
 *  @param color   边线的颜色
 *  @param yesOrNO 是否允许
 */
- (void)setView:(UIView *)view BoaderWithWidth:(CGFloat)width radius:(CGFloat)radius coloc:(UIColor *)color andToBounds:(BOOL)yesOrNO;

/**
 *  截屏
 *
 *  @param view 截取的view
 */
//- (void)takePhotoWithView:(UIView *)view;
/**
 *  返回MBProgress提示
 *
 */
- (void)ShowInfoWithString:(NSString *)messag withTime:(NSTimeInterval)time;
- (void) showMBHudWithString:(NSString *) massage andShowView:(UIView *) view;
//返回SVProgressSuccess
- (void)ShowSuccessWithString:(NSString *)message withTime:(NSTimeInterval)time;
//正在进行中
- (void)ShowWithString:(NSString *)message;
- (void)AliOSSShowWithString:(NSString *)message;
//返回SVProgressError
- (void)ShowErrorWithString:(NSString *)message withTime:(NSTimeInterval)time;
/**
 *  消失SVProgressHUD
 */
- (void)dismissSVProgressHUD;
#pragma mark 处理图片
-(NSData *)handleImage:(UIImage *) item;
//等比缩放
//通过缩放系数
#pragma  mark 缩放图片
- (UIImage *) scaleFromImage: (UIImage *) image toSize: (CGSize) size;
//获取几天后的时间
- (NSDate *)dateWithInt:(NSInteger)dayCount;
//获取当前时间
- (NSString *)dateWithDate:(NSDate *)date;
//获取当前的月和日

- (NSString *)monthAddDay:(NSDate *)date;
#pragma mark - 判断时间
- (int)compareDate:(NSString*)date01 withDate:(NSString*)date02;
#pragma mark  把时间转化为时间戳
-(NSInteger)getTimestamp:(NSString *)time;
#pragma mark  把时间戳转为时间
-(NSString *)getTimeString:(NSString *)timeStamp setDateFormat:(NSString *)dateFormat;
- (NSString *)updateTimeForRow:(NSString * )timeStamp;
/**
 *  根据日期获取周几
 *
 *  @param inputDate 计算的日期
 *
 *  @return 周几
 */
- (NSString *)weekdayStringFromDate:(NSDate*)inputDate;
/**
 *  创建消息
 *
 *  @param name   消息唯一名
 *  @param object 传递的数据
 */
- (void)postNSNotifiCtionCenterWithName:(NSString *)name object:(id)object;
/**
 *  接收消息
 *
 *  @param observer 接受者
 *  @param sel      接收时间
 *  @param name     接收消息名
 *  @param object   传递参数
 */
- (void)addObserverNsNotificationObservr:(id)observer sel:(SEL)sel name:(NSString *)name object:(id)object;
/**
 *  移除消息
 *
 *  @param observer 移除消息者
 */
- (void)cancelNSNotificationWithObserve:(id)observer;
/**
 *  根据数据源按首字母分组
 *
 *  @param arrToSort 要分组的数据源
 *
 *  @return 分组之后的数组  数组中是数组
 */
//-(NSMutableArray *)changeGroup:(NSMutableArray *)arrToSort;
/**
 *  获取首字母
 *
 *  @param index 数组的section
 *
 *  @return 首字母
 */
//- (NSString *)fristWIthIndex:(NSInteger)index;

//邮箱判断
- (BOOL)isEmailAddress:(NSString*)candidate;
/**
 *  手机号码验证
 *
 *  @param mobileNumbel 传入的手机号码
 *
 *  @return 格式正确返回true  错误 返回false
 */
- (BOOL) isMobile:(NSString *)mobileNumbel;

//手机号码验证
- (BOOL) validateMobile:(NSString *)mobile;
//用户名
- (BOOL) validateUserName:(NSString *)name;
//密码
- (BOOL) validatePassword:(NSString *)passWord;

//生成二维码
- (UIImage *)createQRWithString:(NSString *)QRString;

//带样式的二维码
//- (UIImage *)imageWithString:(NSString *)str
//                    codeSize:(CGFloat)size
//                         red:(CGFloat)red
//                       green:(CGFloat)green
//                        blue:(CGFloat)blue
//                 insertImage:(UIImageView *)image
//                 roundRadius:(CGFloat)roundRadius;
//根据颜色生成图片
- (UIImage*) GetImageWithColor:(UIColor*)color andHeight:(CGFloat)height;
///**
// *  返回本机手机号
// *
// *  @return myNumber
// */
//- (NSString *)myNumber;
//阳历转换阴历
-(NSString *)LunarForSolar:(NSDate *)solarDate;
/**
 *  分割之后的字符串
 *  @param string 要分割的字符串
 *  @param stringStyle 分割标识
 *  @return array
 */
- (NSArray *)componentsSeparatedByString:(NSString *)string withComponentsSeparatedStyle:(NSString *)stringStyle;
//判断网络
//- (NSInteger)statusOfInternetStatus;
/**
 *   判断是否有网
 */
//- (BOOL) checkNetworkStatus;
//UIImage转换为NSString
-(NSString*)imageToStringWithImage:(UIImage*)image;
//将base64的字符串转换为图片


//- (void)confirmRecordVoice:(UIView *)self_view;
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

/**
 *  照片旋转（大小超过2M会自动旋转）
 *
 *  @param aImage <#aImage description#>
 *
 *  @return <#return value description#>
 */
- (UIImage *)fixOrientationAction:(UIImage *)aImage;
/**
 *  去除html标签
 *
 *  @param totalTime <#html description#>
 *
 *  @return <#return value description#>
 */

-(NSString *)getMMSSFromSS:(NSInteger )totalTime;
- (void)alertControllerWithViewController:(id) viewController Title:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *) cancelTitle sureButtonTitle:(NSString *) sureTitle cancelAction:(cancelActionBlock)cancelHandler sureAction:(sureActionBlock)sureHandler;

/**url UTF-8转码*/
- (NSString *) stringByAddingUTF8String:(NSString *) url;

//验证身份证号码
-(BOOL)validateIDCardNumber:(NSString *)value;

//字符串转换为16进制数字

- (NSString *)convertStringToHexStr:(NSString *)str;

//字符串转换为BYTE[]

-(NSData*) hexToBytes:(NSString *)str;

//截取byte[]数组
- (void)bytesplit2byte:(Byte[])src orc:(Byte[])orc begin:(NSInteger)begin count:(NSInteger)count;

//16进制字符转整数
- (NSInteger)numberWithHexString:(NSString *)hexString;
//字符串转16进制字符串
- (NSString *)hexStringFromString:(NSString *)string;
//10进制数字转成16进制数字表示
-(NSString *)ToHex:(long long int)tmpid;
//创建nstimer保持连接
-(void)creatSocket;
//重新连接socket
-(void)checkSocket;

-(void)keepConnect;

-(int)calcCrc16buf:(uint8_t[])buf offset:(int)offset len:(int)len;
-(NSData *)convertToJsonData:(NSDictionary *)dict;

- (NSDictionary *)dictionaryWithJsonString:(uint8_t *)buffer lenth:(ssize_t)recvlen;

@end

